#pragma once
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

//抽象迭代器类TVIterator
class TVIterator{
public:
	virtual void setChannel(int i) = 0;
	virtual void next() = 0;
	virtual void previous() = 0;
	virtual bool isLast() = 0;
	virtual string currentChannel() = 0;
	virtual bool isFirst() = 0;
}; 


//抽象聚合类Television
class Television{
public:
	virtual TVIterator* createIterator() = 0;
}; 

//具体迭代器类SkyworthIterator
class SkyworthIterator : public TVIterator{
public:
	SkyworthIterator(vector<string> &tvs):tvs(tvs){
	}
	
	void next(){
		if(currentIndex < tvs.size()){
			currentIndex++;
		}
        cout << currentIndex << endl;
	}
	
	void previous(){
		if(currentIndex > 0){
			currentIndex--;
		}
	}
	
	void setChannel(int i){
		currentIndex = i;
	}
	
	string currentChannel(){
		return tvs[currentIndex];
	}
	
	bool isLast(){
		return currentIndex == tvs.size();
	}
	
	bool isFirst(){
		return currentIndex == 0;
	}
	
private:
	vector<string> &tvs;
	int currentIndex = 0;
};

//具体电视机类SkyworthTeleviosion
class SkyworthTelevision : public Television{
public:
	TVIterator* createIterator(){
		return new SkyworthIterator(tvs);
	}
	
	void addItem(string item){
		tvs.push_back(item);
	}
		
private:
	vector<string> tvs; //这里是存储数据的数据结构，可以自己写，先借vecotr来存储 
}; 